<?php

class Ead_Form_Alunos extends Zend_Form
{

    public function init()
    {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        
        $this->setName('form_'.$controller);
        
        $el = new Zend_Form_Element_Hidden('USU_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))
            ->addFilter('Int');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_CPF');
        $el->setLabel('CPF')
        ->setAttrib('class', 'cpf');
        //->setRequired(true)
        //->addFilter('StripTags')
        //->addFilter('StringTrim')
        //->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_NOME');
        $el->setLabel('Nome')
        ->setRequired(true)
        ->setAttrib('class', 'nome')
        ->addFilter('StripTags')
        ->addFilter('StringTrim')
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_DTNASC');
        $el->setLabel('Data Nascimento')
                ->setAttrib('class', 'data')  
                ->setRequired(true)
                //->setAttrib('readonly',true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $id = $front->getRequest()->getParam('id', 0);
        $uf = '';
        if($id > 0)
        {
            $obj = new Ead_Model_DbTable_Usuarios();
            $row = $obj->fetchRow('USU_ID = ' . $id)->toArray();
            $uf = $row['USU_UF'];
        }
        $el = new Zend_Form_Element_Text('USU_CIDADE');
        $el->setLabel('Cidade')
        ->setRequired(true)  
        ->setAttrib('class', 'cidade res_cidade')    
        ->setDescription('<label class="uf">UF:</label><input type="text" value="'.$uf.'" id="uf" name="uf" class="uf res_uf" maxlength="2" />')
        ->setDecorators(array('ViewHelper',
        array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt')),
        'Errors',))
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_TEL');
        $el->setLabel('Telefone')
                ->setAttrib('class', 'telefone') 
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_PER2');
        $el->setLabel('Qual profissão/curso você busca?')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $this->addElement($el);
                
        $el = new Zend_Form_Element_Text('USU_EMAIL');
        $el->setLabel('Email')
        //->setAttrib('readonly',true)
        ->setAttrib('class', 'email')
        ->setRequired(true)
        ->addFilter('StripTags')
        ->addFilter('StringTrim')
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el= new Zend_Form_Element_Text('USU_LOGIN');
        $el->setLabel('Login')
        ->setAttrib('class', 'login')
        ->setRequired(true)
        ->addFilter('StripTags')
        ->addFilter('StringTrim')
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Password('USU_SENHA');
        $el->setLabel('Senha')
        //->setRequired(true)
        ->addFilter('StripTags')
        ->addFilter('StringTrim')
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Checkbox('USU_STA',array('checked'=>'checked'));
        $el->setLabel('Status');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Checkbox('USU_CENE',array());
        $el->setLabel('Exclusivo para alunos do CENE');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Checkbox('USU_STAEML',array('checked'=>'checked'));
        $el->setLabel('Cadastro Pendente');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('submit',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-button btn-ok');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        //$btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-button btn-cancel">Cancelar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-button btn-cancel');
        $this->addElement($btn);
        
    }


}

